1748. Sum of Unique Elements

You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.

Return the sum of all the unique elements of nums.

 

Example 1:

Input: nums = [1,2,3,2]
Output: 4
Explanation: The unique elements are [1,3], and the sum is 4.

Example 2:

Input: nums = [1,1,1,1,1]
Output: 0
Explanation: There are no unique elements, and the sum is 0.

Example 3:

Input: nums = [1,2,3,4,5]
Output: 15
Explanation: The unique elements are [1,2,3,4,5], and the sum is 15.

 

Constraints:

  • 1 <= nums.length <= 100
  • 1 <= nums[i] <= 100
#1 Two Sum
Easy
#2 Add Two Numbers
Medium
#3 Longest Substring Without Repeating Characters
Medium
#4 Median of Two Sorted Arrays
Hard
#5 Longest Palindromic Substring
Medium
#6 Zigzag Conversion
Medium
#7 Reverse Integer
Medium
#8 String to Integer (atoi)
Medium
#9 Palindrome Number
Easy
#10 Regular Expression Matching
Hard
#11 Container With Most Water
Medium
#12 Integer to Roman
Medium
#13 Roman to Integer
Easy
#14 Longest Common Prefix
Easy
#15 3Sum
Medium
#16 3Sum Closest
Medium
#17 Letter Combinations of a Phone Number
Medium
#18 4Sum
Medium
#19 Remove Nth Node From End of List
Medium
#20 Valid Parentheses
Easy
#21 Merge Two Sorted Lists
Easy
#22 Generate Parentheses
Medium
#23 Merge k Sorted Lists
Hard
#24 Swap Nodes in Pairs
Medium
#25 Reverse Nodes in k-Group
Hard
#26 Remove Duplicates from Sorted Array
Easy
#27 Remove Element
Easy
#28 Find the Index of the First Occurrence in a String
Medium
#29 Divide Two Integers
Medium
#30 Substring with Concatenation of All Words
Hard
#31 Next Permutation
Medium
#32 Longest Valid Parentheses
Hard
#33 Search in Rotated Sorted Array
Medium
#34 Find First and Last Position of Element in Sorted Array
Medium
#35 Search Insert Position
Easy
#36 Valid Sudoku
Medium
#37 Sudoku Solver
Hard
#38 Count and Say
Medium
#39 Combination Sum
Medium
#40 Combination Sum II
Medium
#41 First Missing Positive
Hard
#42 Trapping Rain Water
Hard
#43 Multiply Strings
Medium
#44 Wildcard Matching
Hard
#45 Jump Game II
Medium
#46 Permutations
Medium
#47 Permutations II
Medium
#48 Rotate Image
Medium
#49 Group Anagrams
Medium
#50 Pow(x, n)
Medium